<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>分页 - 组件演示</title>
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="../components/pagination/pagination.css">
</head>
<body>
    <div class="container">
        <header class="header">
            <h1>🚀 openHarmony_Cordova_NutpiDesign</h1>
            <p class="subtitle">组件演示 - 分页</p>
        </header>

        <nav class="demo-nav">
            <a href="../index.html" class="nav-back">← 返回首页</a>
        </nav>

        <main class="main-content">
            <section class="demo-section">
                <h2>📄 分页演示</h2>
                
                <div class="demo-container">
                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>基础分页</h3>
                        <div id="basicPagination"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>带每页显示数量选择</h3>
                        <div id="sizeChangerPagination"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>小尺寸</h3>
                        <div id="smallPagination"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>大尺寸</h3>
                        <div id="largePagination"></div>
                    </div>

                    <div class="demo-item" style="grid-column: 1 / -1;">
                        <h3>禁用状态</h3>
                        <div id="disabledPagination"></div>
                    </div>
                </div>
            </section>

            <section class="demo-section">
                <h2>使用代码</h2>
                <pre><code>// 1. 引入文件
&lt;link rel="stylesheet" href="components/pagination/pagination.css"&gt;
&lt;script src="components/pagination/pagination.js"&lt;/script&gt;

// 2. 创建容器
&lt;div id="paginationContainer"&lt;/div&gt;

// 3. 初始化分页组件
const pagination = new Pagination({
    container: '#paginationContainer',
    total: 100,
    pageSize: 10,
    current: 1,
    onChange: (result) => {
        console.log('当前页:', result.current);
        console.log('每页数量:', result.pageSize);
    }
});

// 4. 设置当前页
pagination.setCurrent(2);

// 5. 获取当前页
const current = pagination.getCurrent();</code></pre>
            </section>
        </main>

        <footer class="footer">
            <p>&copy; 2025 OpenHarmony 三方库适配中心 | MIT License</p>
        </footer>
    </div>

    <script src="../components/pagination/pagination.js"></script>
    <script>
        // 基础分页
        new Pagination({
            container: '#basicPagination',
            total: 100,
            pageSize: 10,
            current: 1,
            onChange: (result) => {
                console.log('基础分页 - 当前页:', result.current);
            }
        });

        // 带每页显示数量选择
        new Pagination({
            container: '#sizeChangerPagination',
            total: 150,
            pageSize: 10,
            current: 1,
            showSizeChanger: true,
            pageSizeOptions: [10, 20, 50],
            onChange: (result) => {
                console.log('分页改变 - 当前页:', result.current);
            },
            onPageSizeChange: (result) => {
                console.log('每页数量改变:', result.pageSize);
            }
        });

        // 小尺寸
        new Pagination({
            container: '#smallPagination',
            total: 100,
            pageSize: 10,
            size: 'small'
        });

        // 大尺寸
        new Pagination({
            container: '#largePagination',
            total: 100,
            pageSize: 10,
            size: 'large'
        });

        // 禁用状态
        new Pagination({
            container: '#disabledPagination',
            total: 100,
            pageSize: 10,
            disabled: true
        });
    </script>

    <style>
        .demo-container {
            display: grid;
            grid-template-columns: 1fr;
            gap: 20px;
            margin-bottom: 20px;
        }

        .demo-item {
            background: var(--bg-light);
            padding: 16px;
            border-radius: 8px;
            overflow: visible;
            position: relative;
        }

        .demo-item h3 {
            margin-top: 0;
            margin-bottom: 16px;
            font-size: 16px;
            color: var(--text-primary);
        }

        .demo-item > div {
            margin-bottom: 12px;
            overflow: visible;
        }

        @media (max-width: 768px) {
            .demo-container {
                grid-template-columns: 1fr;
            }
        }
    </style>
</body>
</html>
